<?php
session_start();
include 'head.php';
if(isset($_POST["flag"]))
{
	
	if($_POST["flag"]=="ly")
	{
		if($_POST["yzm"]!=$_SESSION["img"])
		{
			echo "<script>alert('验证码错误!请勿重复留言');window.location.href='feedback.php'</script>";
		
			return;
		}
		$dates = date("Y-m-d");
		
		$sql = "insert into custom_need(title,content,email,phone,name,dates,flag) 
		values('".$_POST['title']."','".$_POST['content']."','".$_POST['email']."','".$_POST['phone']."','".$_POST['name']."','".$dates."',1)";
		mysql_query($sql);
		
		echo "<script>alert('您的留言已提交');window.location.href='feedback.php'</script>";	
	}
}



?>
<link href="1.css" rel="stylesheet" type="text/css">
<script>
 function reloadYZM(obj)
 {
	 obj.src="validitPicture.php";
 }

 function liuyan()
 {
	 
		if($("#title").val()=="")
		{
			alert("主题不能为空");
			return;
		}
		if($("#content").val()=="")
		{
			alert("内容不能为空");
			return;
		}
		if($("#yzm").val()=="")
		{
			alert("验证码不能为空");
			return;
		}

		$.post("getyzm.php",{flag:"yzm"},function(data){
					
					if($("#yzm").val()==data)
					{
						$("#form1").submit();
					}else
					{
						alert("验证码错误");
					}
			});
		
 }

 function gbcount(obj){

		var total =  document.getElementById("total"); //存最多可输入字符对象
		
		var used =   document.getElementById("used");
		if(obj.value.length>total.value)
		{
			obj.value = obj.value.substring(0,total.value);//超出字部分截取
			
			used.value = obj.value.length;
			alert("不得超过"+total.value+"个字"); 
		}else
		{
			used.value = obj.value.length;
		}
}
</script>
<div id="ym">

	 
	
	 
     <div id="main" style="background:#FFFFFF; width:960px; height:632px;">
	     
		 <div id="dh" style="background:none;width:960px; height:632px;">
		 
	        
	     		<div class="gg2" style="margin-left:16px;background:none">
		     	<?php
				   $sql = "select * from ad where id = 12";
				   $ret = mysql_query($sql);
				   $rcd = mysql_fetch_array($ret);
				 ?>
				 <a href="<?php echo $rcd['link']?>" target='_blank'><img src="<?php echo $rcd['pic_path'];?>" /></a>
	     		</div> 
			 
			 
			
			 <div class="nrdh"><h1 style="text-indent:16px; margin-top:11px;">客户反馈</h1></div>
			 
			 <div class="nrk">
			     <!--客户反馈-->
			 	<div style="margin: 48px 0 0 59px; width:500px;">
						<!--留言主题-->
						<form id="form1" action="feedback.php" method="post">
						<input type="hidden" name="flag" value="ly" />
						<div style="height:24px; line-height:24px; float:left; width:">
							<span style="float:left;">留言主题:<img src="images/User_xh.jpg" style="width:8px; height:8px; margin: 0 7px 0 0px;"/></span>
							<div style="width:119px; height:22px; float:left;">
								<input id="title" name="title" style="width:119px;height:22px;border:1px solid #d1d2d6;" />
									
								
							</div>
						</div>
						<!--留言主题-->
	
				
						<!--留言内容-->
							<div style="height:96px; margin-top:10px; float:left; ">
									<span style="float:left;">留言内容:<img src="images/User_xh.jpg" style="width:8px; height:8px; margin: 0 7px 0 0px;"/></span>
									<div style="width:304px; height:64px; float:left;">
										
										  <textarea id="content" onKeyUp="gbcount(this)" name="content" rows="4" cols="39" style="border:1px solid #d1d2d6;resize:none;"></textarea>
										
										<span style="float:left; color:#999999; width:304px; text-align: left; margin-top:8px;">小于等于<input id="total" disabled style="border:none;background:transparent;width:25px;" value="200"   />字符</span>
									</div>
									<span style="float:left; color:#999999; margin-top:49px; margin-left:5px;">已输入字符<input id="used" disabled style="border:none;background:transparent;width:25px" value="0"  />字</span>
											
							</div>
						<!--留言内容-->
						
						<!--留言邮箱-->
						<div style="width:255px; height:39px; float:left; line-height:24px;">
							<span style="float:left;">您的邮箱:</span>
							<span style=" float:left; margin-left:14px; ">
								<input id="email" name="email" type="text" style="width:176px; height:22px; border:1px solid #d1d2d6;" />
							</span>
							<span style="color:#999999; margin-top:24px; margin-left:75px;">示例邮箱:exmpie@mail.com</span>
							
						</div>
						<!--留言邮箱-->
						
						<!--联系电话-->
						<div style="width:255px; height:39px; float:left; line-height:24px; margin-top:10px;">
							<span style="float:left;">联系电话:</span>
							<span style=" float:left; margin-left:14px; ">
								<input id="phone" name="phone" style="width:176px; height:22px; border:1px solid #d1d2d6;" />
							</span>	
							
						</div>
						<!--联系电话-->
						
						<!--姓名-->
						<div style="width:255px; height:39px; float:left; line-height:24px;">
							<span style="float:left;">姓名:</span>
							<span style=" float:left; margin-left:37px; ">
								<input id="name" name="name" style="width:176px; height:22px; border:1px solid #d1d2d6;" />
							</span>
							
						</div>
						<!--姓名-->
					
						<!--验证码-->
							<div style="height:96px;float:left; line-height:24px;">
									<span style="float:left;">验证码:<img src="images/User_xh.jpg" style="width:8px; height:8px; margin: 0 7px 0 12px;"/></span>
									
									<div style="float:left;width:178px;">
											<input id="yzm" name="yzm" style="width:176px; height:22px; border:1px solid #d1d2d6;" />
										<input type="button" onclick="liuyan()"  style="float:left;width:81px; height:25px; background-color: #000000;margin-top:38px; color:#FFFFFF;" value="发表留言" />
									</div>
									<span style="float:left; color:#999999; margin-top:0px; margin-left:7px;"><img onclick="reloadYZM(this)" style="cursor:pointer;" src="validitPicture.php"/></span>
											
							</div>
						<!--验证码-->
						</form>
				</div>
				<!--客户反馈-->
						
						
						
						
			</div>
			
			 <div class="gg2" style="margin-left:16px; background:none;">
			 <?php
			   $sql = "select * from ad where id = 13";
			   $ret = mysql_query($sql);
			   $rcd = mysql_fetch_array($ret);
			 ?>
			 <a href="<?php echo $rcd['link']?>" target='_blank'><img src="<?php echo $rcd['pic_path'];?>" /></a>
			 </div>
			 
			 
			 
	     </div>
		 
	 </div>
	 
	 
	 
	 <?php include 'bottom.php';?>
</div>